'use strict';

module.exports = app => {
    const {DataTypes} = app.Sequelize;
    const RoomDetail = app.model.define('room_detail', {
        id: { 
            type: DataTypes.UUID,
            defaultValue: app.Sequelize.UUIDV4, 
            primaryKey: true,
            notNull: true,
            unique: true,
            comment: 'ID'
        },
        room_name:{
            type: DataTypes.STRING(20),
            notNull: true,
            comment: '昵称'
        },
        room_id: {
            type: DataTypes.UUID,
            notNull: true,
            comment: '房间ID'
        },
        user_id: {
            type: DataTypes.UUID,
            notNull: true,
            comment: '用户ID'
        },
        user_name: {
            type: DataTypes.STRING(20),
            notNull: true,
            comment: '用户昵称'
        },
        role: {
            type: DataTypes.INTEGER,
            comment: '角色(狼人,预言家..)'
        },
        room_num:{
            type: DataTypes.STRING(6),
            notNull: true,
            len: [6,6],
            comment: '房间号'
        },
        create_time:{
            type:DataTypes.DATE(6),
            defaultValue: app.Sequelize.NOW,
            notNull: true,
            comment: '创建时间'
        },
        is_owners:{
            type: DataTypes.BOOLEAN,
            notNull: true,
            defaultValue:false,
            comment: '是否是房主'
        },
        has_img:{
            type: DataTypes.BOOLEAN,
            notNull: true,
            defaultValue:false,
            comment: '是否有头像'
        },
        ws_key:{
            type:DataTypes.STRING(100),
            comment:"websocekt的key"
        }
    },
    {
        timestamps: false
    }
  );
  return RoomDetail;
};